import static org.junit.Assert.*;

public class NGuessNumberTest {

    @org.junit.Test
    public void generateAnswerTest() {
        //检查答案数字数量是否为4
        int[] result = new NGuessNumber().generateAnswer();
        assertEquals(result.length,4);
        //其中是否无重复数字
        for (int Result:result) {
            assertEquals(Result<10 && Result>=0,true);
        }
        //以及数字是否都在0-9之间
        int c = 0;
        for (int a : result){
            int i = a;
            for (int b = c+1;b<result.length;b++){
                assertEquals(result[b] != i,true);
            }
            c++;
        }
    }

    //使用断言检查玩家猜测的数字数量是否为4
    @org.junit.Test
    public void getPlayerInputTest() {
        NGuessNumber nGuessNumber = new NGuessNumber();
        nGuessNumber.guesses = new int[]{1,2,3,4};
        assertEquals(nGuessNumber.guesses.length,4);
    }

    @org.junit.Test
    public void compareGuessAnswer(){
        NGuessNumber nGuessNumber = new NGuessNumber();
        nGuessNumber.answers = new int[]{1,2,3,4};
        nGuessNumber.guesses = new int[]{1,2,3,4};
        nGuessNumber.compareGuessAnswer();
        assertEquals(nGuessNumber.count[0],4);
    }

    @org.junit.Test
    public void isWin(){
        NGuessNumber nGuessNumber = new NGuessNumber();
        nGuessNumber.count[0] = 4;
        boolean is = nGuessNumber.isWin();
        assertEquals(is,true);
    }
}